package com.mingqijia.gassafety.authority.api.web.facade;

import com.mingqijia.gassafety.authority.api.req.role.CreateRoleReqDTO;
import com.mingqijia.gassafety.authority.api.req.role.QueryRoleReqDTO;
import com.mingqijia.gassafety.authority.api.req.role.UpdateRoleReqDTO;
import com.mingqijia.gassafety.authority.api.resp.role.RoleInfoRespDTO;
import com.mingqijia.gassafety.shared.utils.commonUtils.PageUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

/**
 * REST接口
 * @author Damon S.
 * @version v0.2
 * @date 2021-06-19
 */
@Api(tags = "控制台--角色")
@RequestMapping(value = "/console/v1/roles", produces = MediaType.APPLICATION_JSON_VALUE)
public interface RoleManageFacade {

    @GetMapping("/{roleIdOrName}")
    @ApiImplicitParam(name = "roleIdOrName", value = "角色ID或名称", dataType = "String")
    @ApiOperation(value = "获取角色详情", notes = "返回角色详情")
    RoleInfoRespDTO findRoleById(@PathVariable String roleIdOrName);

    @GetMapping
    @ApiOperation(value = "查询角色", notes = "返回角色列表")
    PageUtil<RoleInfoRespDTO> findRole(@Valid QueryRoleReqDTO req);

    @PostMapping
    @ApiOperation(value = "新建角色", notes = "返回是否新建成功")
    String createRole(@RequestBody@Valid CreateRoleReqDTO req);

    @PutMapping
    @ApiOperation(value = "编辑角色", notes = "返回是否编辑成功")
    void updateRole(@RequestBody@Valid UpdateRoleReqDTO req);

    @DeleteMapping
    @ApiImplicitParam(name = "roleId", value = "角色Id列表", dataType = "Array")
    @ApiOperation(value = "删除角色", notes = "返回是否删除成功")
    void removeRole(String[] roleId);

    @PutMapping("/{roleId}/{state}")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "roleId", value = "角色Id", dataType = "String"),
            @ApiImplicitParam(name = "state", value = "启用状态", dataType = "String")
    })
    @ApiOperation(value = "角色上下线(0停用，1启用)", notes = "返回是否成功")
    void switchRole(@PathVariable String roleId, @PathVariable Integer state);
}
